package club.hicode.daydayup.netty.udp.client;

import com.github.sd4324530.jtuple.Tuple2;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

/**
 * 键值对
 *
 * @author Liu Chunfu
 * @date 2018-07-09 下午3:18
 **/
public class KV {

    private static final ConcurrentHashMap<String, Tuple2<Lock, Condition>> MAP = new ConcurrentHashMap<>(20);


    public static void put(String id, Lock lock, Condition condition) {
        MAP.put(id, Tuple2.with(lock, condition));
    }

    public static Tuple2<Lock, Condition> get(String id) {
        return MAP.get(id);
    }

    public static void clear(String id) {
        MAP.remove(id);
    }
}
